package com.wan37.logic.skill.impl;

import com.wan37.logic.skill.BaseAOESkill;
import com.wan37.logic.skill.BaseONESkill;
import com.wan37.protobuf.constant.CommonBase;
import com.wan37.logic.domain.vo.AllRoleVO;
import com.wan37.logic.domain.vo.SkillVO;
import com.wan37.logic.global.reference.SpringContextHolder;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 技能造成结果逻辑处理
 *
 * @author : luoyong
 * @date : 2020-06-03 11:02
 **/
@Component
public class SkillManager {

    /**
     * 技能主要逻辑处理
     *
     * @param skillVO
     * @param allRoleVO
     * @param allRoleVO2
     */
    public Map<String, Map<String, Long>> handler(SkillVO skillVO, AllRoleVO allRoleVO,
                                                  AllRoleVO allRoleVO2) {

        //消耗角色HP
        allRoleVO.getNumberMap().put(CommonBase.HP, allRoleVO.getNumberMap().get(CommonBase.HP) - skillVO.getCostHP());

        //找到对应的技能处理器
        BaseONESkill baseONESkill = SpringContextHolder.getBean(skillVO.getLabel());
        //执行技能处理逻辑
        Map<String, Map<String, Long>> allRoleVONumberMap = baseONESkill.execute(skillVO, allRoleVO, allRoleVO2);
        return allRoleVONumberMap;
    }

    /**
     * 技能主要逻辑处理
     *
     * @param skillVO
     * @param allRoleVO
     * @param allRoleVOList
     */
    public Map<String, Map<String, Long>> handler(SkillVO skillVO, AllRoleVO allRoleVO,
                                                  List<AllRoleVO> allRoleVOList) {

        //消耗角色HP
        allRoleVO.getNumberMap().put(CommonBase.HP, allRoleVO.getNumberMap().get(CommonBase.HP) - skillVO.getCostHP());

        //找到对应的技能处理器
        BaseAOESkill baseAOESkill = SpringContextHolder.getBean(skillVO.getLabel());
        //执行技能处理逻辑
        Map<String, Map<String, Long>> allRoleVONumberMap = baseAOESkill.execute(skillVO, allRoleVO, allRoleVOList);
        return allRoleVONumberMap;
    }
}
